package com.frame.demo.app;

import android.view.View;

import com.frame.demo.rest.RestError;
import com.frame.demo.mvp.BasePresenter;
import com.frame.demo.mvp.BaseView;

/**
 * @author yuefeng
 * @version 3.3.1
 * @date 15/12/14
 * * 用于绑定和解绑presenter
 */
public abstract class TitleBaseBindPresenterActivity<P extends BasePresenter>
        extends TitleBaseActivity implements BaseView {
    public P mPresenter;


    public void initActivity(View view) {
        this.mPresenter = getPresenter();
        if (null != mPresenter) {
            mPresenter.attachView(this);
        }
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        if (null != mPresenter) {
            mPresenter.detachView();
        }
    }

    public abstract P getPresenter();

    @Override
    public void onExceptionDispose(RestError pRestError) {
        commonExceptionDispose(pRestError);
    }

    @Override
    public void onShowLoadingDialog() {
        showLoadingDialog();
    }

    @Override
    public void onDismissLoadingDialog() {
        dimissLoadingDialog();
    }

}
